import { getMyInfo } from '../../apis/index';
//  初始化 state
const state = sessionStorage.getItem('user_state') ? JSON.parse(sessionStorage.getItem('user_state')) : {
    userInfo : {}
};

const getters = {
    getMyInfo : (state) => {
        if (Object.keys(state.userInfo).length === 0){
            getMyInfo().then(res => state.userInfo = res.data);
        }
        return state.userInfo;
    }
};

const mutations = {

};

const actions = {

};

export default {
    state : state,
    getters : getters,
    mutations : mutations,
    actions : actions
};
